function InversePairs(data)
{
    // write code here
    function mergeSort(left,right){
      if(left >= right){
        return 0
      }
      let mid = left + Math.floor((right - left) / 2)
      let cnt = mergeSort(left,mid) + mergeSort(mid+1,right)
      let i = left
      let j = mid + 1
      let pos = left
      while(i <= mid && j <= right){
        if(data[i] < data[j]){
          temp[pos] = data[i]
          i++
        }else{
          temp[pos] = data[j]
          j++
          cnt += (mid - i + 1)
        }
        pos++
      }
      for(let k = i;k <= mid;k++){
        temp[pos] = data[k]
        pos++
      }
      for(let k = j;k <= right;k++){
        temp[pos] = data[k]
        pos++
      }
      data.splice(left,right-left+1,...temp.slice(left,right+1))
      return cnt
    }
    let n = data.length
    if(n === 0 || n === 1) return 0
    let temp = new Array(n)
    return mergeSort(0,n-1) % 1000000007
}
module.exports = {
    InversePairs : InversePairs
};